package service.impl;

import common.consts.Consts;
import dao.LiveCityDao;
import domain.LiveCity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import service.ServiceResponse;

import java.util.List;

/**
 * Created by chen on 2015/7/10.
 *
 * @author chen <chen@youjianghr.com>
 */
@Service
public class LiveCityServiceImpl extends ServiceBase implements service.LiveCityService {


    private static final Logger logger = LoggerFactory.getLogger(LiveCityServiceImpl.class);

    @Autowired
    private LiveCityDao liveCityDao;


    @Override
    @Transactional(readOnly = true)
    public ServiceResponse getAllCityWithPriorityDesc() {

        List<LiveCity> list = liveCityDao.getAllCityWithPriorityDesc();

        if (list == null || list.size() <= 0) {
            return ServiceResponse.fail(Consts.i18nKey.LIVECITY_EMPTY);
        }

        return ServiceResponse.success().with("liveCities", list);
    }

    public void setLiveCityDao(LiveCityDao liveCityDao) {
        this.liveCityDao = liveCityDao;
    }
}
